﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Duality;
using Duality.Components;
using Duality.Components.Renderers;
using Duality.Components.Physics;

using OpenTK;

namespace MagicPrototype.TestStuff
{
	[Serializable]
	[RequiredComponent(typeof(Transform))]
	[RequiredComponent(typeof(SpriteRenderer))]
    public class SpriteOffsetAdjuster : Component, ICmpUpdatable, ICmpEditorUpdatable
    {
		void ICmpUpdatable.OnUpdate()
		{
			Transform transform = this.GameObj.Transform;
			SpriteRenderer sprite = this.GameObj.GetComponent<SpriteRenderer>();
			if (sprite != null)
			{
				sprite.Offset = -(int)transform.Pos.Y;
			}
		}
		void ICmpEditorUpdatable.OnUpdate()
		{
			(this as ICmpUpdatable).OnUpdate();
		}
	}
}
